package cn.zh.planmanager.domain.plan.convert;

import cn.zh.planmanager.domain.plan.model.entity.Plan;
import cn.zh.planmanager.domain.plan.model.value.ProjectInfo;
import cn.zh.planmanager.infrastructure.entity.PlanEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.lang.NonNull;

/**
 * @author zh
 */
public class PlanConvert {

    public static Plan convertToPlan(@NonNull PlanEntity entity){
        Plan plan = new Plan();
        BeanUtils.copyProperties(entity, plan);

        ProjectInfo projectInfo = new ProjectInfo();
        projectInfo.setName(entity.getProjectName());
        projectInfo.setContent(entity.getProjectContent());
        plan.setProjectInfo(projectInfo);

        return plan;
    }
}
